<template>
	<view class="content bg-light">
		<tabsTop tabName="明细"></tabsTop>
		<view style="min-height: 578px;">
			<!-- 图标和tab -->
			<view class="fixed-element">
				<view class="icon-tab-container p-2 justify-between">
					<!-- logo -->
					<view class="flex align-center">
						<image class="icon rounded-circle" :src="logo" mode="aspectFit"></image>
						<text class="tab-text">小康龙江</text>
					</view>
					<!-- 我的卡 -->
					<view class="flex align-center">
						<image></image>
						<view class="tab-text">我的卡</view>
					</view>
				</view>
				<view class="tab-bar p-1">
					<text class="tab-item" :class="{ 'active': currentTab === 'trade' }"
						@click="switchTab('trade')">交易记录</text>
					<text class="tab-item" :class="{ 'active': currentTab === 'buycard' }"
						@click="switchTab('buycard')">购卡记录</text>
					<text class="tab-item" :class="{ 'active': currentTab === 'transfer' }"
						@click="switchTab('transfer')">转赠记录</text>
					<view class="tab-indicator" :style="{ left: leftPosition, width: tabWidth }"></view>
				</view>
			</view>
			<!-- 交易记录 -->
			<view v-show="currentTab === 'trade'">
				<!-- 暂无交易记录 -->
				<view style="margin-top: 100px;">
					<view class="notrade">暂无交易记录</view>
				</view>
			</view>
			<!-- 购卡记录 -->
			<view v-show="currentTab === 'buycard'">
				<view style="margin-top: 100px;">
					<view class="notrade">暂无购卡记录</view>
				</view>
			</view>
			<!-- 转赠记录 -->
			<view v-show="currentTab === 'transfer'">
				<view style="margin-top: 100px;">
					<view class="notrade">暂无转赠记录</view>
				</view>
			</view>
		</view>
		<!-- 底部赞助信息 -->
		<botSponsor></botSponsor>
	</view>
</template>

<script>
	const app = getApp();
	import tabsTop from "@/components/tabs/tabs-top.vue";
	import botSponsor from "@/components/botsponsor/sponsor.vue"
	export default {
		components: { //轮播图组件
			tabsTop,
			botSponsor // 底部赞助商
		},
		data() {
			return {
				currentTab: 'trade',
				tabs: ['trade', 'buycard', 'transfer'], // 选项卡数组
				trade: 0,
				principal: 0,
				gifts: 0,
				logo: app.globalData.Domain_ICON+'/sponsor.jpg'
			}
		},
		computed: {
			leftPosition() {
				return `calc(${this.tabs.indexOf(this.currentTab) * (100 / this.tabs.length)}% + 12%)`; // 设置 left 样式，初始值为 5%
			},
			tabWidth() {
				return `calc(30% / ${this.tabs.length})`; // 设置选项卡宽度
			}
		},
		onReady() {

		},
		onLoad() {

		},
		methods: {
			switchTab(tab) {
				this.currentTab = tab;
			},
			goGiftDetails() {
				uni.navigateTo({
					url: "/pages/my/giftDetails",
				})
			}
		}
	}
</script>

<style>
	.fixed-element {
		position: fixed;
		top: 63px;
		left: 0;
		width: 100%;
		z-index: 999;
	}

	.icon-tab-container {
		display: flex;
		align-items: center;
	}

	.icon {
		width: 20px;
		height: 20px;
	}

	.tab-text {
		margin-left: 10px;
		font-size: 10px;
	}

	.tab-bar {
		display: flex;
		border-bottom: 1px solid #ccc;
		justify-content: space-around;
	}

	.tab-item {
		text-align: center;
		padding: 10px;
		font-size: 14px;
		cursor: pointer;
	}

	.active {
		color: #007BFF;
	}

	.tab-indicator {
		position: absolute;
		top: 86px;
		left: 0;
		height: 4px;
		background-color: #00bfff;
		transition: left 0.3s;
	}

	image {
		width: 20px;
		height: 20px;
	}

	.notrade {
		font-size: 13px;
		text-align: center;
		margin-top: 180px;
		color: #9d9d9d;
	}
</style>